home *** CD-ROM | disk | FTP | other *** search
- head 1.7;
- branch ;
- access ;
- symbols sprited:1.7.1;
- locks ; strict;
- comment @ * @;
-
-
- 1.7
- date 88.11.03.08.42.16; author ouster; state Exp;
- branches 1.7.1.1;
- next 1.6;
-
- 1.6
- date 88.11.02.16.19.13; author ouster; state Exp;
- branches ;
- next 1.5;
-
- 1.5
- date 88.09.30.08.35.30; author brent; state Exp;
- branches ;
- next 1.4;
-
- 1.4
- date 88.07.29.17.39.09; author ouster; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 88.06.29.09.15.27; author ouster; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 88.06.21.11.36.53; author ouster; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.06.19.14.31.39; author ouster; state Exp;
- branches ;
- next ;
-
- 1.7.1.1
- date 91.11.27.13.12.38; author kupfer; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.7
- log
- @Bug in the change I made yesterday.
- @
- text
- @/*
- * open.c --
- *
- * Procedure to map from Unix open system call to Sprite.
- *
- * Copyright (C) 1986 Regents of the University of California
- * All rights reserved.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/lib/c/unixSyscall/RCS/open.c,v 1.6 88/11/02 16:19:13 ouster Exp $ SPRITE (Berkeley)";
- #endif not lint
-
- #include <sprite.h>
- #include <stdio.h>
- #include <fs.h>
- #include "compatInt.h"
- #include <sys/file.h>
- #include <errno.h>
- #include <status.h>
-
-
- /*
- *----------------------------------------------------------------------
- *
- * open --
- *
- * Procedure to map from Unix open system call to Sprite Fs_Open.
- * Mostly this has to map the usageFlags argument
- *
- * Results:
- * UNIX_ERROR is returned upon error, with the actual error code
- * stored in errno. A file descriptor is returned upon success.
- *
- * Side effects:
- * Opening a file sets up state in the filesystem until the file is
- * closed.
- *
- *----------------------------------------------------------------------
- */
-
- /* VARARGS2 */
- int
- open(pathName, unixFlags, permissions)
- char *pathName; /* The name of the file to open */
- register int unixFlags; /* O_RDONLY O_WRONLY O_RDWR O_NDELAY
- * O_APPEND O_CREAT O_TRUNC O_EXCL */
- int permissions; /* Permission mask to use on creation */
- {
- int streamId; /* place to hold stream id allocated by
- * Fs_Open */
- ReturnStatus status; /* result returned by Fs_Open */
- register int useFlags = 0; /* Sprite version of flags */
-
- /*
- * Convert unixFlags to FS_READ, etc.
- */
-
- if (unixFlags & FASYNC) {
- fprintf(stderr, "open - FASYNC not supported\n");
- errno = EINVAL;
- return(UNIX_ERROR);
- }
- if (unixFlags & O_RDWR) {
- useFlags |= FS_READ|FS_WRITE;
- } else if (unixFlags & O_WRONLY) {
- useFlags |= FS_WRITE;
- } else {
- useFlags |= FS_READ;
- }
- if (unixFlags & FNDELAY) {
- useFlags |= FS_NON_BLOCKING;
- }
- if (unixFlags & FAPPEND) {
- useFlags |= FS_APPEND;
- }
- if (unixFlags & FTRUNC) {
- useFlags |= FS_TRUNC;
- }
- if (unixFlags & FEXCL) {
- useFlags |= FS_EXCLUSIVE;
- }
- if (unixFlags & O_MASTER) {
- useFlags |= FS_PDEV_MASTER;
- }
- if (unixFlags & O_PFS_MASTER) {
- useFlags |= FS_PFS_MASTER;
- }
- if (unixFlags & FCREAT) {
- useFlags |= FS_CREATE;
- }
-
- status = Fs_Open(pathName, useFlags, permissions, &streamId);
- if (status != SUCCESS) {
- errno = Compat_MapCode(status);
- return(UNIX_ERROR);
- } else {
- return(streamId);
- }
- }
- @
-
-
- 1.7.1.1
- log
- @Initial branch for Sprite server.
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/unixSyscall/RCS/open.c,v 1.7 88/11/03 08:42:16 ouster Exp $ SPRITE (Berkeley)";
- @
-
-
- 1.6
- log
- @I don't understand why there were TWO calls to Fs_Open. This
- was causing problems for mode O_CREAT|O_EXCL (the open wasn't
- failing if the file already existed). So I took out the first
- call.
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: open.c,v 1.5 88/09/30 08:35:30 brent Exp $ SPRITE (Berkeley)";
- d89 1
- a89 1
- if (unixFlags & O_EXCL) {
- @
-
-
- 1.5
- log
- @Added O_PFS_MASTER flag for pseudo-filesystems
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: open.c,v 1.4 88/07/29 17:39:09 ouster Exp $ SPRITE (Berkeley)";
- d89 3
- a93 4
- if ((status == FS_FILE_NOT_FOUND) && (unixFlags & FCREAT)) {
- useFlags |= FS_CREATE;
- status = Fs_Open (pathName, useFlags, permissions, &streamId);
- }
- @
-
-
- 1.4
- log
- @Lint.
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: open.c,v 1.3 88/06/29 09:15:27 ouster Exp $ SPRITE (Berkeley)";
- d84 4
- a87 1
- useFlags |= FS_NEW_MASTER;
- @
-
-
- 1.3
- log
- @Support pseudo-devices, fix bug in handling O_WRONLY.
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: open.c,v 1.2 88/06/21 11:36:53 ouster Exp $ SPRITE (Berkeley)";
- d42 1
- @
-
-
- 1.2
- log
- @Must include status.h.
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: open.c,v 1.1 88/06/19 14:31:39 ouster Exp $ SPRITE (Berkeley)";
- d55 1
- a55 5
- * Convert unixFlags to FS_READ, etc. Because O_RDONLY == 0, and
- * O_WRONLY == 1, and O_RDWR == 2, you can add 1 to the flags to
- * get the low order bit set when you need reading, and the second
- * bit set when you need writing. The next flag up is 0x4, so it
- * doesn't get affected. Isn't this great...
- d57 1
- a57 1
- unixFlags += 1;
- d63 5
- a67 1
- if (unixFlags & FREAD) {
- a69 3
- if (unixFlags & FWRITE) {
- useFlags |= FS_WRITE;
- }
- d82 2
- a83 2
- if (unixFlags & FREAD) {
- useFlags |= FS_READ;
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: open.c,v 1.7 87/09/26 04:56:45 deboor Exp $ SPRITE (Berkeley)";
- d14 1
- a14 1
- #include "sprite.h"
- d16 1
- a16 1
- #include "fs.h"
- d20 1
- @
-